<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品分类 - 商品商城</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    <link href="/css/shop.css" rel="stylesheet">
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm sticky-top">
        <div class="container">
            <a class="navbar-brand" href="/shop">
                <i class="bi bi-shop"></i> 商品商城
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/shop">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/shop/products">所有商品</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="/shop/categories">商品分类</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/shop/promotions">促销商品</a>
                    </li>
                </ul>
                <form class="d-flex me-3" action="/shop/search" method="get">
                    <input class="form-control me-2" type="search" name="keyword" placeholder="搜索商品...">
                    <button class="btn btn-outline-primary" type="submit">
                        <i class="bi bi-search"></i>
                    </button>
                </form>
                <ul class="navbar-nav">
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown">
                            <i class="bi bi-person-circle"></i> 我的账户
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="/auth/login">登录</a></li>
                            <li><a class="dropdown-item" href="/auth/register">注册</a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="/shop/profile">个人中心</a></li>
                            <li><a class="dropdown-item" href="/shop/orders">我的订单</a></li>
                            <li><a class="dropdown-item" href="/shop/cart">购物车</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 页面头部 -->
    <div class="page-header">
        <div class="container">
            <h1 class="fw-bold">商品分类</h1>
            <p class="lead mb-0">浏览所有商品分类，找到您需要的商品</p>
        </div>
    </div>

    <div class="container">
        <!-- 分类网格 -->
        <div class="row" th:if="${categories != null and !#lists.isEmpty(categories)}">
            <div class="col-md-3 col-sm-6" th:each="category : ${categories}">
                <a th:href="@{/shop/category(id=${category.id})}" class="text-decoration-none">
                    <div class="category-card">
                        <i th:class="${category.icon ?: 'bi bi-grid'}"></i>
                        <h5 th:text="${category.categoryName}">分类名称</h5>
                        <p class="text-muted" th:text="${category.description ?: '暂无描述'}">分类描述</p>
                        <span class="badge bg-primary rounded-pill" th:text="${category.productCount} + ' 件商品'">0 件商品</span>
                    </div>
                </a>
            </div>
        </div>

        <!-- 无分类提示 -->
        <div class="no-products" th:if="${categories == null or #lists.isEmpty(categories)}">
            <i class="bi bi-grid"></i>
            <h4>暂无商品分类</h4>
            <p>请先在管理后台添加商品分类</p>
            <a href="/shop/products" class="btn btn-primary">浏览所有商品</a>
        </div>
    </div>

    <!-- 页脚 -->
    <footer class="footer">
        <div class="container">
            <div class="row">
                <div class="col-md-4">
                    <h5>商品商城</h5>
                    <p>提供优质商品，满足您的购物需求</p>
                </div>
                <div class="col-md-4">
                    <h5>快速链接</h5>
                    <ul>
                        <li><a href="/shop">首页</a></li>
                        <li><a href="/shop/products">所有商品</a></li>
                        <li><a href="/shop/categories">商品分类</a></li>
                        <li><a href="/shop/promotions">促销商品</a></li>
                    </ul>
                </div>
                <div class="col-md-4">
                    <h5>客户服务</h5>
                    <ul>
                        <li><a href="#">帮助中心</a></li>
                        <li><a href="#">退换货政策</a></li>
                        <li><a href="#">配送说明</a></li>
                        <li><a href="#">联系我们</a></li>
                    </ul>
                </div>
            </div>
            <div class="footer-bottom">
                <p>&copy; 2023 商品商城. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>